package com.allnas.jpa.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDateTime;

/**
 * @author zhaojin
 */
@Entity
@Table(name = "t_user")
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class User {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "user_name")
    private String userName;

    private Integer age;

    @Column(name = "creator_id", updatable = false)
    @CreatedBy
    private Integer creatorId;

    @Column(name = "create_time",updatable = false)
    @CreatedDate
    private LocalDateTime createTime;

    @Column(name = "update_id")
    @LastModifiedBy
    private Integer updateId;

    @Column(name = "update_time")
    @LastModifiedDate
    private LocalDateTime updateTime;
}
